//
//  ByFocusControl.m
//  caipiao_ios
//
//  Created by mc on 2018/9/5.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByFocusControl.h"

@implementation ByFocusControl

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        [self addSubview:backgroundView];
        
        
        UIImageView *smallView = [[UIImageView alloc] init];
        [backgroundView addSubview:smallView];
        [smallView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(backgroundView).offset(18);
            make.centerY.equalTo(backgroundView).offset(0);
            make.size.mas_equalTo(CGSizeMake(15, 15));
        }];
        
        UILabel *titleLabel = [[UILabel alloc] init];
        [backgroundView addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(smallView.mas_right).offset(5);
            make.right.equalTo(backgroundView).offset(-5);
            make.centerY.equalTo(backgroundView).offset(0);
            make.height.mas_equalTo(@15);
        }];
        titleLabel.font = FONT(13);
        titleLabel.textAlignment = NSTextAlignmentCenter;
        self.backgroundView = backgroundView;
        self.smallView = smallView;
        self.titleLabel = titleLabel;
    }
    return self;
}

- (void)setHasFocused:(BOOL)hasFocused{
    _hasFocused = hasFocused;
    
    
    if (hasFocused) {
        self.backgroundView.image = [UIImage imageNamed:@"ditu2已关注"];
        self.smallView.image = [UIImage imageNamed:@"yiguanzhu关注"];
        self.titleLabel.text = @"已关注";
        self.titleLabel.textColor = BY_THEME_COLOR;
    }else{
        self.backgroundView.image = [UIImage imageNamed:@"ditu未关注"];
        self.smallView.image = [UIImage imageNamed:@"weiguanzhu未关注"];
        self.titleLabel.text = @"关注";
        self.titleLabel.textColor = [UIColor whiteColor];
    }
    
    
    
}




@end
